<template>
  <h4>简单事件</h4>
  <div>{{ count }}</div>
  <button v-on:click="count++">增加1</button>
  <button v-on:click="addCount">增加2</button>
  <h4>参数事件</h4>
  <button @click="show('hello')">显示</button>
  <h4>事件传参</h4>
  <p @click="getName(item, $event)" v-for="(item, index) in name" :key="index">{{ item }}</p>
</template>

<script>
  export default{
    data(){
      return{
        count: 0,
        name: ["小明","小黄","刘备"],
      }
    },
    methods:{
      addCount(e){
        console.log(e);
        e.target.innerHTML = "Add" + this.count;
        this.count++;
      },
      show(str){
        console.log(str);
        this.count++;
      },
      getName(name,e){
        console.log(name);
        console.log(e);
      }
    }
  }

</script>
